public class Solution {
    public double findMaxAverage(int[] nums, int k) {

        int sum=0;
        int maxSum=0;
        for(int i=0;i<k;i++){
            //先算出一个窗口的和
            sum+=nums[i];
        }
        maxSum=sum;
        for(int i=k;i<nums.length;i++){
            //再滑动，取大的值
            sum=sum-nums[i-k]+nums[i];
            maxSum=Math.max(sum,maxSum);
        }


        return maxSum*1.0/k;
    }
}